package com.xlh.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 权限枚举
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum PermissionEnum {

    COURSE_DIRECTION_HIDE("course_direction_hide", "用户对首页的课程体系隐藏控制"),
    PRACTICE_ANSWER_CONTROL("practice_answer_control", "用户对随堂练习答案显隐控制");

    private String code;

    private String message;

    public static PermissionEnum getByCode(String code) {
        for (PermissionEnum permissionEnum : PermissionEnum.values()) {
            if (Objects.equals(permissionEnum.getCode(), code)) {
                return permissionEnum;
            }
        }
        return null;
    }

}
